# js手写代码系列

# push

const arr = [1, 2, 3];
Array.prototype.myPush = function() {
    const { length } = arguments;
    for (let i = 0; i < length; i++) {
        this[this.length] = arguments[i];
    }
    return this.length;
}

arr.myPush(4,5,6);
console.log(arr);	// [1, 2, 3, 4, 5, 6]